﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Threading;
using System.Net;
using System.Net.Sockets;

namespace NetworkingLibrary.Servers
{
    public interface IServer
    {
        int MaxFlowRate
        {
            get;
            set;
        }
        DateTime LastSendTime
        {
            get;
            set;
        }
        
        event Events.ClientConnectDelegate OnClientConnect;
        event Events.ClientDisconnectDelegate OnClientDisconnect;
        event Events.MaxConnectionsDelegate OnMaxConnections;
        event Events.MessageReceivedDelegate OnMessageReceived;
        event Events.ErrorDelegate OnError;

        int BufferSize
        {
            get;
            set;
        }
        bool Initialised
        {
            get;
        }
        bool Terminating
        {
            get;
            set;
        }

        int MaxConnections
        {
            get;
            set;
        }

        Dictionary<Guid, Clients.IClient> AllClients
        {
            get;
        }
                
        bool Initialise(int Port, string Addr);
        bool Start(int Port, string Addr, int? MaxConnections = null);
        bool Stop();

        bool Send(byte[] TheBuffer);
        bool SendTo(byte[] TheBuffer, Guid ToID);
        bool Send(byte[] TheBuffer, Guid ExcludeID);
        bool Send(Messages.MessageObject TheMessage);
        bool SendTo(Messages.MessageObject TheMessage, Guid ToId);
        bool Send(Messages.MessageObject TheMessage, Guid ExcludeID);
    }
}
